#include <cstdio>
#include <cstring>

int n, m;

int dp[1005];

int main( void )
{
	freopen( "input.txt", "r", stdin );

	while( scanf( "%d %d", &n, &m ) == 2 ) {
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;

		for( int i = 0; i < m; ++i ) {
			int x; scanf( "%d", &x );

			for( int j = x; j <= n; ++j )
				dp[j] = (dp[j] + dp[j-x]) % 10007;
		}

		printf( "%d\n", dp[n] );
	}

	return 0;
}
